using System;
using System.Collections.Generic;
using System.Text;

using Planar.PT120;

namespace Test
{
    class Program
    {
        public static void Main(string[] Args)
        {
            try
            {
                foreach (string name in System.IO.Ports.SerialPort.GetPortNames())
                {
                    Console.WriteLine(name);
                }
                Driver.Instance.CommandReceived += new EventHandler<CommandEventArgs>(driver_CommandReceived);
                Driver.Instance.Start();
                while (true) { }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadLine();
            }
            finally
            {
                Driver.Instance.Stop();
            }
        }

        static void driver_CommandReceived(object sender, CommandEventArgs e)
        {
            Console.WriteLine(
                string.Format("{0} x: {1} y: {2}",
                e.Command.CommandType,
                e.Command.X,
                e.Command.Y));
        }
    }
}
